﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="qst_dataentry_edit.aspx.cs" Inherits="Ccit.OA.Question.qst_dataentry_edit" %>
<%@ Register TagPrefix="ccit" Namespace="Ccit.ServerControls" Assembly="Ccit.ServerControls.ActionForm" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>问卷管理-个人问卷填报</title>
    <script language="javascript" type="text/javascript" src="../script/jquery.js"></script>
    <script language="javascript" type="text/javascript" src="../script/StringClass_Ext.js"></script>
    <script language="javascript" type="text/javascript" src="../script/jsonlib.js"></script>
    <script language="javascript" src="../script/jwindow.js" type="text/javascript"></script>
    <script language="javascript" src="../script/jcontrol.js" type="text/javascript"></script>
    <script language="javascript" src="../script/jbase64.js" type="text/javascript"></script>
    <script type="text/jscript">
        function doSave()
        {
            var msMes ={};
            var endtime = document.getElementById("lblEndTime").innerText;
            var mydate = new Date();
            var month  = mydate.getMonth()+1;
            var vTime = mydate.getYear()+"-"+month+"-"+mydate.getDate(); 
            var check = compareDate(endtime,vTime)   
            if(check==false)
            {
                msMes.id =  document.getElementById("_hidWTId").value; 
                msMes.qid = document.getElementById("_hidsRecid").value;
                msMes.Record = GetDetail();
                msMes.MsOptions = GetOptions();
                var jsonExpr = JSON.stringify(msMes,function(key,value){return value;}); 
                msMes = null;
                PageMethods.DoSave(jsonExpr,ClientBack); 
            }
        }
        /* 判断起始日期大小 */
        function compareDate(DateOne,DateTwo)   
        {
            var OneMonth = DateOne.substring(5,DateOne.lastIndexOf ("-"));   
            var OneDay = DateOne.substring(DateOne.length,DateOne.lastIndexOf ("-")+1);   
            var OneYear = DateOne.substring(0,DateOne.indexOf ("-"));   
              
            var TwoMonth = DateTwo.substring(5,DateTwo.lastIndexOf ("-"));   
            var TwoDay = DateTwo.substring(DateTwo.length,DateTwo.lastIndexOf ("-")+1);   
            var TwoYear = DateTwo.substring(0,DateTwo.indexOf ("-"));   
              
            if (Date.parse(OneMonth+"/"+OneDay+"/"+OneYear) <=   
            Date.parse(TwoMonth+"/"+TwoDay+"/"+TwoYear))   
            {   
                alert("该问卷已结束，不允许填报!");
                return true;   
            }   
            else  
            {   
                return false;   
            } 
        }  
        function ClientBack(vResult)
        {
             eval("resultObj ="+vResult)
                if(resultObj.result!="-999")
                {                   
                    alert(resultObj.message);
                    if(document.getElementById("_hidOpenType").value!="")
                    {
                         parent.window.opener.location.reload();
	                     window.close();
                    }
                    return true;
                }
                else
                {
                    alert(resultObj.message);
                    return false;
                }
                resultObj = null;
        }
        function GetDetail()
        {
            var orowcount = document.getElementById("_hidCount").value;
            var DetailArray=new Array();
            for(var i=0;i<orowcount;i++)
            { 
                var radiovalue=0;
                var chkvalu=0; 
                var msList={};
                var wtid =  document.getElementById("_hidWTId").value;
                var swtid = wtid.split(",");
                //var k = swtid[i];
                var radio = document.getElementsByName("radio_"+i);
                var chkType = document.getElementsByName("checkbox_"+i);
                if(radio.length>0)
                {
                    for(var j=0;j<radio.length;j++)
                    {                        
                       if(radio[j].checked ==true)
                        {			    
                            radiovalue = radio[j].value;	 
                              
//                             radiovalue = radio[j].value;
//                             msList.oid = radiovalue; 
//                             DetailArray.push(msList1);   
                        } 
                    }
                } 
                if(chkType.length>0)
                {
                    for(var k=0;k<chkType.length;k++)
                    {
                        if(chkType[k].checked ==true)
                        {
                             chkvalu += (chkvalu == "0") ? +chkType[k].value : "," + +chkType[k].value;
//                             var msList2={};
//                             chkvalu = chkType[k].value;
//                             msList.qid = chkvalu; 
//                             DetailArray.push(msList2);                              
                        }
                    }
                } 
 
                //alert(msList.oid+"=="+msList.qid);
                 msList.qmid = swtid[i];  
                 msList.oid = radiovalue; 
                 msList.qid = chkvalu; 
                 DetailArray.push(msList);
            }
            return DetailArray;
        }
        function GetOptions()
        {
            var orowcount = document.getElementById("_hidCount").value;
            var radiovalue=0;
            var chkvalu=0; 
            var DetailArray=new Array();
            for(var i=0;i<orowcount;i++)
            { 
                var wtid =  document.getElementById("_hidWTId").value;
                var swtid = wtid.split(",");
                var msList={};
                var vtlens = document.getElementsByName("txtareaQT_"+i);
                if(vtlens.length>0)
                {
                    var txt = document.getElementById("txtareaQT_"+i).value;                
                    msList.options = txt;
                }
                msList.qmid = swtid[i];
                DetailArray.push(msList);
            }
            return DetailArray;
        }
    </script>
</head>
<body>
    <ccit:ActionForm id="form1" runat="server">
      <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
    </asp:ScriptManager> 
    <input type="hidden" id="_hidCount" runat="server" />
    <input type="hidden" id="_hidWTId" runat="server" />
    
    <input type="hidden" id="_hidsRecid" runat="server" />
    <!----------------------------------------------------->
     <input type="hidden" id="_hidMaxCount" runat="server" value="0" />
      <input type="hidden" id="_hidCurCount" runat="server" />
    <!----------------------------------------------------->
    <input type="hidden" id="_hidType" runat="server" />
    <input type="hidden" id="_hidOpenType" runat="server" />
     <table cellpadding="0" cellspacing="0" width="98%" align="center">
            <tr>
                <td>
                    <table class="tbToolbar" cellpadding="0" cellspacing="0" width="98%" align="center">
                            <tr> 
                                <td align="left">
                                    <div class="tbSeparator"></div>
                                </td>
                                <td width="100%" class="titlebar">  
                                    调查问卷-填报管理
                                </td>    
                                <td align="right" runat="server" id="tdPage">
                                     <nobr>
                                      您目前需要回答的问卷共有<font color="red"><asp:Label ID="lblMsgCount" runat="server" Text="0"></asp:Label></font>份,
                                       当前为第<font color="red"><asp:Label ID="lblCurCount" runat="server" Text="0"></asp:Label></font>份&nbsp;
                                         <asp:LinkButton ID="lnkFirst" runat="server"  class="linktext" 
                                            onclick="lnkFirst_Click">第一份</asp:LinkButton>&nbsp;
                                          <asp:LinkButton ID="lnkUp" runat="server" class="linktext" 
                                        onclick="lnkUp_Click">上一份</asp:LinkButton>&nbsp;
                                       <asp:LinkButton ID="lnkDown" runat="server" class="linktext"
                                            onclick="lnkDown_Click" >下一份</asp:LinkButton>&nbsp
                                        <asp:LinkButton ID="lnkLast" runat="server"  class="linktext" 
                                            onclick="lnkLast_Click">最后一份</asp:LinkButton>&nbsp;
                                     </nobr> 
                                </td> 
                                <td align="right">
                                    <div class="tbSeparator"></div>
                                </td>
                            </tr> 
                        </table>
                    </td>
               </tr>
          <tr>
             <td>
                    <table class="tableborder" cellpadding="0" cellspacing="0" width="98%" align="center" runat="server">
                          <tr>
                            <td width="10%" valign="top" class="pformleft" align="right">问卷标题</td>
                            <td class="pformright" colspan="3">
                                <asp:Label ID="lblTitle" runat="server">&nbsp;</asp:Label></td>
                          </tr>
                          <tr>
                            <td width="10%"  class="pformleft" align="right">问卷说明</td>
                            <td class="pformright" colspan="3">
                                <asp:Label ID="lblExplain" runat="server">&nbsp;</asp:Label></td>
                          </tr>
                          <tr>
                            <td width="10%"  class="pformleft" align="right">填报类型</td>
                            <td class="pformrightline" >
                                <asp:Label ID="lblType" runat="server">&nbsp;</asp:Label></td>
                            <td width="10%"  class="pformleft" align="right">截止时间</td>
                            <td class="pformright" >
                                <asp:Label ID="lblEndTime" runat="server">&nbsp;</asp:Label></td>
                          </tr>
                          <tr>
                             <td width="98%" colspan="4" class="pformleft"> 
                                 <table class="tableborder" runat="server" cellpadding="0" cellspacing="0" width="98%" align="center" >
                                   <tr>
                                        <td >
                                        </td>
                                   </tr>
                                    <tr class="pformstrip">
                                        <td align="left" width="70%">
                                          <b>>>>问题列表</b>
                                        </td>  
                                        <td align="right"  >
                                            <nobr>　 
			　　                            </nobr>            
                                        </td>               
                                    </tr>         
                                 </table> 
                                 <table class="tableborder" cellpadding="0" cellspacing="0" width="98%" align="center" runat="server" id="tbProduct"> 
                                </table>
                                 <table  class="tableborder" cellpadding="0" cellspacing="0" width="98%" align="center" runat="server">
                                 <tr class="pformstrip">
                                    <td align="center"><input type="button" id="btnSave" runat="server" value="保存"  class="button" onclick="doSave()" style="display:none"/></td>
                                 </tr>
                                </table>
                             </td>
                          </tr>
                    </table>
                 </td>
          </tr> 
        </table>
    </ccit:ActionForm>
</body>
</html>
